﻿package frEngine.shader
{
    import __AS3__.vec.*;
    import baseEngine.core.*;
    import baseEngine.system.*;
    import com.gengine.resource.*;
    import com.gengine.resource.info.*;
    import flash.display.*;
    import flash.display3D.*;
    import flash.geom.*;
    import frEngine.*;
    import frEngine.core.*;
    import frEngine.manager.*;
    import frEngine.shader.filters.*;
    import frEngine.shader.filters.fragmentFilters.*;
    import frEngine.shader.filters.fragmentFilters.extra.*;
    import frEngine.shader.filters.vertexFilters.*;
    import frEngine.shader.registType.*;

    public class MaterialParams extends Object
    {
        public var needRebuild:Boolean = false;
        private var _killValue:Vector.<Number>;
        public var colorOffsetValue:Vector.<Number>;
        private var _colorMultiplier:Vector.<Number>;
        private var _uvValue:Vector.<Number>;
        public var UVrotateValue:Vector.<Number>;
        public var uvSclaeCenter2:Vector.<Number>;
        public var needRegetBone:Boolean = false;
        public var vertexFilter:VertexFilter;
        public var fragmentFilter:FragmentFilter;
        public var cullFace:String = "back";
        public var sourceFactor:String = "one";
        public var destFactor:String = "zero";
        public var depthWrite:Boolean = true;
        public var depthCompare:String = "lessEqual";
        public var program:FrProgram3D;
        private var _filterList:Array;
        private var _blendMode:int = 0;
        private var _twoSided:Boolean = false;
        public var uvRotateBaseAngle:Number = 0;
        public var alphaBaseValue:Number = 1;
        private var _colorBaseValue:Number = 16777215;
        private var _SimpleWaterParames:Array;
        private var _SimpleCubeTexArray:Array;
        private var _SimpleWaterTexArray:Array;
        private var _rimBaseColor:Number = 0;
        public var outLightColor:Vector3D;
        public var outLightStrength:Number = 1.4;
        public var outLightAsBgColor:Boolean = false;
        public var rimLightStrengthBase:Number = 1;
        public var uvScaleBasePoint:Point;
        public var UVoffsetBase:Point;
        private var _uvMaskFilter:UVMaskFilter;
        private var _colorScreenFilter:ColoredScreenFilter;
        private var _herizionKillFilter:HerizonKilFilter;
        private var _uvRepeat:Boolean = true;
        private var _useColoredScreen:Boolean = false;
        private var _enableMask:Boolean = false;
        private var _enableXray:Boolean = false;
        private var _enableOutLight:Boolean = false;
        private var _enableBaseRimlight:Boolean = false;
        private var _enableAnimRimlight:Boolean = false;
        private var _isOpenHerizionKil:Boolean = false;
        private var _enableSimpleWater:Boolean = false;
        private var _enableFog:Boolean = false;
        private var _enableUvRoll:Boolean = false;
        private var _enableSecondRollTexture:Boolean = false;
        private var _secondRollTexturefileName:String = "";
        private var _lastTickTime:Number = 0;
        private var _uvRollSpeed:Point;
        private var _FogColor:uint = 4.29497e+009;
        private var _rimLightFilter:RimLightFilter;
        private var _skinNum:int = 0;
        private var _openMaskSolubility:Boolean = false;
        public var id:int = 0;
        private var _vertexNormalFilter:VertexNormalFilter;
        private var _underLevelFilter:UnderLevelFilter;
        private static var _id:int = 0;

        public function MaterialParams()
        {
            this._killValue = this.Vector.<Number>([0, 0, 0, 0]);
            this.colorOffsetValue = this.Vector.<Number>([1, 1, 1, 1]);
            this._colorMultiplier = this.Vector.<Number>([1, 1, 1, 1]);
            this._uvValue = this.Vector.<Number>([1, 1, 0, 0]);
            this.UVrotateValue = this.Vector.<Number>([0.5, 0.5, 0, -1]);
            this.uvSclaeCenter2 = this.Vector.<Number>([1, 1, 0, 0]);
            this._filterList = new Array();
            this._SimpleWaterParames = new Array(0.005, 0.007, 0.003, 0.004, "water_normals.jpg", "water_normals1.jpg", "snow_positive_x.jpg", "snow_negative_x.jpg", "snow_positive_y.jpg", "snow_negative_y.jpg", "snow_positive_z.jpg", "snow_negative_z.jpg");
            this._SimpleCubeTexArray = new Array(null, null, null, null, null, null);
            this._SimpleWaterTexArray = new Array(null, null);
            this.outLightColor = new Vector3D(0, 1, 0, 1);
            this.uvScaleBasePoint = new Point(1, 1);
            this.UVoffsetBase = new Point();
            this._uvRollSpeed = new Point();
            this.id = _id + 1;
            return;
        }// end function

        public function get uvValue2() : Vector.<Number>
        {
            return this._uvValue;
        }// end function

        public function set uvValue2(param1:Vector.<Number>) : void
        {
            this._uvValue = param1;
            if (!this.program)
            {
                var _loc_3:* = this._uvValue;
                this.fragmentFilter.uvValue = this._uvValue;
                return;
            }
            var _loc_2:* = this.program.getParamByName("{uvValue}", false);
            var _loc_3:* = param1;
            _loc_2.value = param1;
            return;
        }// end function

        public function setVertexFilter(param1:VertexFilter) : void
        {
            if (this.vertexFilter == param1)
            {
                return;
            }
            this.vertexFilter = param1;
            this.needRebuild = true;
            return;
        }// end function

        public function get vertexFilterType() : int
        {
            if (this.vertexFilter)
            {
                return this.vertexFilter.type;
            }
            return -1;
        }// end function

        public function setFragmentFilter(param1:FragmentFilter) : void
        {
            if (this.fragmentFilter != param1)
            {
                this.fragmentFilter = param1;
                this.needRebuild = true;
                this.reInitFragParams();
            }
            return;
        }// end function

        public function reInitFragParams() : void
        {
            if (this.fragmentFilter)
            {
                this.fragmentFilter.killValue = this._killValue;
                this.fragmentFilter.colorOffsetValue = this.colorOffsetValue;
                this.fragmentFilter.colorMultiplier = this._colorMultiplier;
                this.fragmentFilter.uvValue = this._uvValue;
                this.fragmentFilter.uvSclaeCenter2 = this.uvSclaeCenter2;
                this.fragmentFilter.UVrotate = this.UVrotateValue;
            }
            return;
        }// end function

        final public function set colorKillvalue(param1:Number) : void
        {
            if (param1 == this._killValue[0])
            {
                return;
            }
            var _loc_2:* = param1;
            this._killValue[2] = param1;
            var _loc_2:* = _loc_2;
            this._killValue[1] = _loc_2;
            this._killValue[0] = _loc_2;
            return;
        }// end function

        final public function get colorKillvalue() : Number
        {
            return this._killValue[0];
        }// end function

        final public function get alphaKillvalue() : Number
        {
            return this._killValue[3];
        }// end function

        final public function set alphaKillvalue(param1:Number) : void
        {
            if (param1 == this._killValue[3])
            {
                return;
            }
            this._killValue[3] = param1;
            return;
        }// end function

        final public function set uvRepeat(param1:Boolean) : void
        {
            if (param1 == this._uvRepeat)
            {
                return;
            }
            this._uvRepeat = param1;
            this.needRebuild = true;
            return;
        }// end function

        final public function get uvRepeat() : Boolean
        {
            return this._uvRepeat;
        }// end function

        public function setMaskTextureUrl(param1:String) : void
        {
            if (this.uvMaskFilter.maskTexture3D)
            {
                if (this.uvMaskFilter.maskTexture3D.request != param1)
                {
                    this.uvMaskFilter.maskTexture3D = Resource3dManager.instance.getTexture3d(param1, Texture3D.MIP_NONE);
                    this.needRebuild = true;
                }
            }
            else
            {
                this.uvMaskFilter.maskTexture3D = Resource3dManager.instance.getTexture3d(param1, Texture3D.MIP_NONE);
            }
            return;
        }// end function

        public function get coloredScreen() : Boolean
        {
            return this._useColoredScreen;
        }// end function

        public function set coloredScreen(param1:Boolean) : void
        {
            if (this._useColoredScreen == param1)
            {
                return;
            }
            this._useColoredScreen = param1;
            this.checkToRemvoe(!this._useColoredScreen, !this._useColoredScreen, this.colorScreenFilter);
            this.needRebuild = true;
            return;
        }// end function

        public function setMaskRotateAngle(param1:Number, param2:Number, param3:Number, param4:String, param5:Boolean) : void
        {
            var _loc_6:* = param4 == null || param4.length == 0;
            var _loc_7:* = _loc_6;
            this.checkToRemvoe(_loc_6, _loc_7, this.uvMaskFilter);
            if (!_loc_6)
            {
                this.uvMaskFilter.changeUVMaskValue(param1, param2, param3);
                this.setMaskTextureUrl(param4);
                if (param5 != this.uvMaskFilter.showMaskEnabled)
                {
                    this.uvMaskFilter.showMaskEnabled = param5;
                    this.needRebuild = true;
                }
            }
            return;
        }// end function

        public function get colorScreenFilter() : ColoredScreenFilter
        {
            if (!this._colorScreenFilter)
            {
                this._colorScreenFilter = new ColoredScreenFilter();
            }
            return this._colorScreenFilter;
        }// end function

        public function get uvMaskFilter() : UVMaskFilter
        {
            if (!this._uvMaskFilter)
            {
                this._uvMaskFilter = new UVMaskFilter();
                this._uvMaskFilter.openSolubility = this._openMaskSolubility;
            }
            return this._uvMaskFilter;
        }// end function

        public function set openMaskSolubility(param1:Boolean) : void
        {
            this._openMaskSolubility = param1;
            if (this.uvMaskFilter.openSolubility != param1)
            {
                this.uvMaskFilter.openSolubility = param1;
                this.needRebuild = true;
            }
            return;
        }// end function

        private function get herizionKillFilter() : HerizonKilFilter
        {
            if (!this._herizionKillFilter)
            {
                this._herizionKillFilter = new HerizonKilFilter();
            }
            return this._herizionKillFilter;
        }// end function

        public function setUvRotateBase(param1:Number) : void
        {
            this.uvRotateBaseAngle = param1;
            this.UVrotateValue[2] = param1;
            return;
        }// end function

        public function get isOpenHerizionKil() : Boolean
        {
            return this._isOpenHerizionKil;
        }// end function

        public function set isOpenHerizionKil(param1:Boolean) : void
        {
            if (this._isOpenHerizionKil == param1)
            {
                return;
            }
            this._isOpenHerizionKil = param1;
            var _loc_2:* = !param1;
            var _loc_3:* = _loc_2;
            this.checkToRemvoe(_loc_2, _loc_3, this.herizionKillFilter);
            return;
        }// end function

        public function set colorBase(param1:uint) : void
        {
            this._colorBaseValue = param1;
            this.colorOffsetValue[0] = (param1 >> 16 & 255) / 255;
            this.colorOffsetValue[1] = (param1 >> 8 & 255) / 255;
            this.colorOffsetValue[2] = (param1 & 255) / 255;
            return;
        }// end function

        public function get colorBase() : uint
        {
            return this._colorBaseValue;
        }// end function

        public function setAlphaBase(param1:Number) : void
        {
            this.colorOffsetValue[3] = param1;
            this.alphaBaseValue = param1;
            return;
        }// end function

        public function setBrightness(param1:Number) : void
        {
            this._colorMultiplier[3] = param1;
            return;
        }// end function

        private function checkToRemvoe(param1:Boolean, param2:Boolean, param3:FilterBase) : Boolean
        {
            var _loc_5:FilterBase = null;
            var _loc_4:* = this.hasFilter(param3.type);
            if (param1)
            {
                if (_loc_4 && param2)
                {
                    this.removeFilteByType(param3.type, false);
                }
            }
            else if (!_loc_4)
            {
                this.addFilte(param3);
            }
            else
            {
                _loc_5 = this.getFilterByTypeId(param3.type);
                if (_loc_5 != param3)
                {
                    this.removeFilte(_loc_5);
                    this.addFilte(param3);
                }
            }
            return param1;
        }// end function

        public function set filterList(param1:Array) : void
        {
            if (this._filterList == param1)
            {
                return;
            }
            this._filterList = param1;
            this.needRebuild = true;
            return;
        }// end function

        public function get filterList() : Array
        {
            return this._filterList;
        }// end function

        public function addFilte(param1:FilterBase, param2:Boolean = false) : void
        {
            if (!param1)
            {
                return;
            }
            var _loc_3:* = this.hasFilter(param1.type);
            var _loc_4:Boolean = false;
            if (param2)
            {
                if (_loc_3)
                {
                    this.removeFilte(param1);
                }
                _loc_4 = true;
            }
            else if (!_loc_3)
            {
                _loc_4 = true;
            }
            if (_loc_4)
            {
                this._filterList.push(param1);
                this.needRebuild = true;
            }
            return;
        }// end function

        public function removeFilteByType(param1:int, param2:Boolean = true) : void
        {
            var _loc_3:* = this.getFilterByTypeId(param1);
            if (_loc_3)
            {
                this.removeFilte(_loc_3, param2);
            }
            return;
        }// end function

        public function removeFilte(param1:FilterBase, param2:Boolean = true) : void
        {
            var _loc_3:int = 0;
            if (!param1)
            {
                return;
            }
            if (this.hasFilter(param1.type))
            {
                _loc_3 = this._filterList.indexOf(param1);
                this._filterList.splice(_loc_3, 1);
                if (param2)
                {
                    param1.dispose();
                }
                this.needRebuild = true;
            }
            return;
        }// end function

        public function getFilterByTypeId(param1:int) : FilterBase
        {
            var _loc_2:int = 0;
            var _loc_4:FilterBase = null;
            var _loc_3:* = this._filterList.length;
            _loc_2 = 0;
            while (_loc_2 < _loc_3)
            {
                
                _loc_4 = this._filterList[_loc_2];
                if (_loc_4.type == param1)
                {
                    return _loc_4;
                }
                _loc_2++;
            }
            return null;
        }// end function

        public function hasFilter(param1:int) : Boolean
        {
            var _loc_2:* = this.getFilterByTypeId(param1);
            return _loc_2 != null;
        }// end function

        public function get twoSided() : Boolean
        {
            return this.cullFace == Context3DTriangleFace.NONE;
        }// end function

        public function cloneFrom(param1:MaterialParams) : void
        {
            this.vertexFilter = param1.vertexFilter.clone() as VertexFilter;
            this.fragmentFilter = param1.vertexFilter.clone() as FragmentFilter;
            this._filterList = param1._filterList.concat();
            this.setBlendMode(param1.blendMode);
            this.depthWrite = param1.depthWrite;
            this.cullFace = param1.cullFace;
            this.setAlphaBase(param1.alphaBaseValue);
            this.colorBase = param1._colorBaseValue;
            this.setBrightness(param1._colorMultiplier[3]);
            this.coloredScreen = param1.coloredScreen;
            this.outLightStrength = param1.outLightStrength;
            this.outLightAsBgColor = param1.outLightAsBgColor;
            this._uvMaskFilter = param1._uvMaskFilter;
            this._openMaskSolubility = param1._openMaskSolubility;
            this.uvRepeat = param1._uvRepeat;
            this.colorKillvalue = param1.colorKillvalue;
            this.isOpenHerizionKil = param1.isOpenHerizionKil;
            this.enableOutLight = param1._enableOutLight;
            this.outLightColor.copyFrom(param1.outLightColor);
            this.setUvRotateBase(param1.uvRotateBaseAngle);
            this.setRimBaseColor(param1.rimBaseColor, param1.enableBaseRimlight);
            this._useColoredScreen = param1._useColoredScreen;
            this._uvValue = param1._uvValue;
            this.needRebuild = true;
            return;
        }// end function

        public function set twoSided(param1:Boolean) : void
        {
            if (this._twoSided == param1)
            {
                return;
            }
            this._twoSided = param1;
            if (param1)
            {
                this.cullFace = Context3DTriangleFace.NONE;
            }
            else
            {
                this.cullFace = Context3DTriangleFace.BACK;
            }
            return;
        }// end function

        public function get blendMode() : int
        {
            return this._blendMode;
        }// end function

        public function dispose() : void
        {
            var _loc_1:FilterBase = null;
            this.program = null;
            this.setMaskRotateAngle(0, 0, 0, null, false);
            this.alphaBaseValue = 1;
            for each (_loc_1 in this._filterList)
            {
                
                _loc_1.dispose();
            }
            this._filterList = new Array();
            if (this._uvMaskFilter)
            {
                this._uvMaskFilter.dispose();
                this._uvMaskFilter.openSolubility = false;
            }
            this._openMaskSolubility = false;
            if (this.vertexFilter)
            {
                this.vertexFilter.dispose();
            }
            if (this.fragmentFilter)
            {
                this.fragmentFilter.dispose();
            }
            this.setVertexFilter(null);
            this.setFragmentFilter(null);
            this.needRegetBone = false;
            this.cullFace = Context3DTriangleFace.BACK;
            this.sourceFactor = Context3DBlendFactor.ONE;
            this.destFactor = Context3DBlendFactor.ZERO;
            this.depthWrite = true;
            this.depthCompare = "lessEqual";
            this._blendMode = 0;
            this._twoSided = false;
            this._rimBaseColor = 0;
            this._uvRepeat = true;
            this.colorKillvalue = 0;
            this.alphaKillvalue = 0;
            this._enableMask = false;
            this._enableXray = false;
            this._enableOutLight = false;
            this._enableBaseRimlight = false;
            this._enableAnimRimlight = false;
            this._isOpenHerizionKil = false;
            this._enableSimpleWater = false;
            this._enableFog = false;
            this._enableUvRoll = false;
            this._enableSecondRollTexture = false;
            this._useColoredScreen = false;
            this._secondRollTexturefileName = "";
            this._skinNum = 0;
            var _loc_2:int = 0;
            this._killValue[3] = 0;
            var _loc_2:* = _loc_2;
            this._killValue[2] = _loc_2;
            var _loc_2:* = _loc_2;
            this._killValue[1] = _loc_2;
            this._killValue[0] = _loc_2;
            var _loc_2:int = 1;
            this.uvSclaeCenter2[1] = 1;
            this.uvSclaeCenter2[0] = _loc_2;
            var _loc_2:int = 0;
            this.uvSclaeCenter2[3] = 0;
            this.uvSclaeCenter2[2] = _loc_2;
            var _loc_2:int = 1;
            this.colorOffsetValue[3] = 1;
            var _loc_2:* = _loc_2;
            this.colorOffsetValue[2] = _loc_2;
            var _loc_2:* = _loc_2;
            this.colorOffsetValue[1] = _loc_2;
            this.colorOffsetValue[0] = _loc_2;
            this._colorBaseValue = 16777215;
            var _loc_2:int = 1;
            this._colorMultiplier[3] = 1;
            var _loc_2:* = _loc_2;
            this._colorMultiplier[2] = _loc_2;
            var _loc_2:* = _loc_2;
            this._colorMultiplier[1] = _loc_2;
            this._colorMultiplier[0] = _loc_2;
            var _loc_2:int = 1;
            this.uvScaleBasePoint.y = 1;
            this.uvScaleBasePoint.x = _loc_2;
            var _loc_2:int = 0;
            this.UVoffsetBase.y = 0;
            this.UVoffsetBase.x = _loc_2;
            this.setUvRotateBase(0);
            this.SetUvRoll(false, 0, 0);
            return;
        }// end function

        public function setBlendMode(param1:int) : void
        {
            this._blendMode = param1;
            switch(this._blendMode)
            {
                case EBlendType.BLEND_NONE:
                {
                    this.sourceFactor = Context3DBlendFactor.ONE;
                    this.destFactor = Context3DBlendFactor.ZERO;
                    return;
                }
                case EBlendType.BLEND_ADDITIVE:
                {
                    this.sourceFactor = Context3DBlendFactor.ONE;
                    this.destFactor = Context3DBlendFactor.ONE;
                    return;
                }
                case EBlendType.BLEND_LIGHT:
                {
                    this.sourceFactor = Context3DBlendFactor.SOURCE_COLOR;
                    this.destFactor = Context3DBlendFactor.ONE;
                    return;
                }
                case EBlendType.BLEND_ALPHA0:
                {
                    this.sourceFactor = Context3DBlendFactor.ONE;
                    this.destFactor = Context3DBlendFactor.ONE_MINUS_SOURCE_ALPHA;
                    return;
                }
                case EBlendType.BLEND_ALPHA1:
                {
                    this.sourceFactor = Context3DBlendFactor.DESTINATION_ALPHA;
                    this.destFactor = Context3DBlendFactor.ONE_MINUS_SOURCE_COLOR;
                    return;
                }
                case EBlendType.BLEND_ALPHA2:
                {
                    this.sourceFactor = Context3DBlendFactor.DESTINATION_ALPHA;
                    this.destFactor = Context3DBlendFactor.ONE_MINUS_SOURCE_ALPHA;
                    return;
                }
                case EBlendType.BLEND_ALPHA3:
                {
                    this.sourceFactor = Context3DBlendFactor.SOURCE_ALPHA;
                    this.destFactor = Context3DBlendFactor.ONE_MINUS_SOURCE_ALPHA;
                    return;
                }
                case EBlendType.BLEND_COLOR:
                {
                    this.sourceFactor = Context3DBlendFactor.SOURCE_COLOR;
                    this.destFactor = Context3DBlendFactor.ONE_MINUS_SOURCE_COLOR;
                    return;
                }
                case EBlendType.BLEND_SCREEN:
                {
                    this.sourceFactor = Context3DBlendFactor.ONE;
                    this.destFactor = Context3DBlendFactor.ONE_MINUS_SOURCE_COLOR;
                    return;
                }
                case EBlendType.BLEND_OVERLAYER:
                {
                    this.sourceFactor = Context3DBlendFactor.DESTINATION_COLOR;
                    this.destFactor = Context3DBlendFactor.ONE;
                    return;
                }
                case EBlendType.BLEND_FOG:
                {
                    this.sourceFactor = Context3DBlendFactor.DESTINATION_COLOR;
                    this.destFactor = Context3DBlendFactor.ZERO;
                    return;
                }
                case EBlendType.BLEND_MASKED:
                {
                    this.sourceFactor = Context3DBlendFactor.ONE_MINUS_DESTINATION_ALPHA;
                    this.destFactor = Context3DBlendFactor.ONE;
                    return;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function get enableMask() : Boolean
        {
            return this._enableMask;
        }// end function

        public function set enableMask(param1:Boolean) : void
        {
            this._enableMask = param1;
            return;
        }// end function

        public function get enableXray() : Boolean
        {
            return this._enableXray;
        }// end function

        public function set enableXray(param1:Boolean) : void
        {
            this._enableXray = param1;
            return;
        }// end function

        public function get enableOutLight() : Boolean
        {
            return this._enableOutLight;
        }// end function

        public function set enableOutLight(param1:Boolean) : void
        {
            this._enableOutLight = param1;
            return;
        }// end function

        public function get rimBaseColor() : Number
        {
            return this._rimBaseColor;
        }// end function

        public function get enableBaseRimlight() : Boolean
        {
            return this._enableBaseRimlight;
        }// end function

        public function get enableAnimRimlight() : Boolean
        {
            return this._enableAnimRimlight;
        }// end function

        private function get rimLightFilter() : RimLightFilter
        {
            if (!this._rimLightFilter)
            {
                this._rimLightFilter = new RimLightFilter();
            }
            return this._rimLightFilter;
        }// end function

        private function get vertexNormalFilter() : VertexNormalFilter
        {
            if (!this._vertexNormalFilter)
            {
                this._vertexNormalFilter = new VertexNormalFilter();
            }
            return this._vertexNormalFilter;
        }// end function

        public function set enableAnimRimlight(param1:Boolean) : void
        {
            if (param1 == this._enableAnimRimlight)
            {
                return;
            }
            this._enableAnimRimlight = param1;
            var _loc_2:* = !this._enableAnimRimlight;
            var _loc_3:* = _loc_2 && !this._enableBaseRimlight;
            this.checkToRemvoe(_loc_2, _loc_3, this.rimLightFilter);
            _loc_3 = _loc_3 && !this._enableSimpleWater;
            this.checkToRemvoe(_loc_2, _loc_3, this.vertexNormalFilter);
            return;
        }// end function

        public function setRimBaseColor(param1:Number, param2:Boolean, param3:Number = 1.3) : void
        {
            if (param2)
            {
                this._rimBaseColor = param1;
                this.rimLightFilter.rimColor[0] = (this._rimBaseColor >> 16 & 255) / 255;
                this.rimLightFilter.rimColor[1] = (this._rimBaseColor >> 8 & 255) / 255;
                this.rimLightFilter.rimColor[2] = (this._rimBaseColor & 255) / 255;
                this.rimLightFilter.StrengthValue = param3;
                this.rimLightStrengthBase = param3;
            }
            if (this._enableBaseRimlight == param2)
            {
                return;
            }
            this._enableBaseRimlight = param2;
            var _loc_4:* = !this._enableBaseRimlight;
            var _loc_5:* = _loc_4 && !this._enableAnimRimlight;
            this.checkToRemvoe(_loc_4, _loc_5, this.rimLightFilter);
            this.checkToRemvoe(_loc_4, _loc_5, this.vertexNormalFilter);
            return;
        }// end function

        public function get skinNum() : int
        {
            return this._skinNum;
        }// end function

        public function set skinNum(param1:int) : void
        {
            if (this._skinNum == param1)
            {
                return;
            }
            this._skinNum = param1;
            this.needRebuild = true;
            return;
        }// end function

        private function get underLevelFilter() : UnderLevelFilter
        {
            if (!this._underLevelFilter)
            {
                this._underLevelFilter = new UnderLevelFilter(1);
            }
            return this._underLevelFilter;
        }// end function

        public function get unlevelAlpha() : Number
        {
            return this.underLevelFilter.alpha;
        }// end function

        public function set unlevelAlpha(param1:Number) : void
        {
            if (this.underLevelFilter.alpha == param1)
            {
                return;
            }
            var _loc_2:* = param1 >= 1;
            var _loc_3:* = _loc_2;
            this.checkToRemvoe(_loc_2, _loc_3, this.underLevelFilter);
            this.underLevelFilter.alpha = param1;
            return;
        }// end function

        public function setOutLightColor(param1:Number) : void
        {
            this.outLightColor.x = (param1 >> 16 & 255) / 255;
            this.outLightColor.y = (param1 >> 8 & 255) / 255;
            this.outLightColor.z = (param1 & 255) / 255;
            return;
        }// end function

        public function set SimpleWaterParames(param1:Array) : void
        {
            this._SimpleWaterParames = param1;
            return;
        }// end function

        public function get SimpleWaterParames() : Array
        {
            return this._SimpleWaterParames;
        }// end function

        public function set enableSimpleWater(param1:Boolean) : void
        {
            this._enableSimpleWater = param1;
            if (!param1)
            {
                if (this.hasFilter(FilterType.SimpleWaterNormalFilter))
                {
                    this.removeFilteByType(FilterType.SimpleWaterNormalFilter);
                    this._SimpleCubeTexArray.length = 0;
                    this._SimpleWaterTexArray.length = 0;
                }
                if (!this._enableAnimRimlight && this.hasFilter(FilterType.VertexNormalFilter))
                {
                    this.removeFilteByType(FilterType.VertexNormalFilter);
                }
            }
            else
            {
                if (!this.hasFilter(FilterType.VertexNormalFilter))
                {
                    this.addFilte(this.vertexNormalFilter);
                }
                if (!this.hasFilter(FilterType.SimpleWaterNormalFilter))
                {
                    if (this.fragmentFilter is TextureFilter)
                    {
                        this.loadWaterWaveMaps();
                    }
                }
            }
            return;
        }// end function

        public function get enableSimpleWater() : Boolean
        {
            return this._enableSimpleWater;
        }// end function

        private function loadWaterWaveMaps() : void
        {
            var _loc_1:* = this.SimpleWaterParames[4];
            var _loc_2:* = this.SimpleWaterParames[5];
            if (_loc_1 && _loc_2)
            {
                this._SimpleWaterTexArray.length = 0;
                LoaderManager.instance.load(_loc_1, this.completeWaterWaveEvent);
                LoaderManager.instance.load(_loc_2, this.completeWaterWaveEvent);
            }
            return;
        }// end function

        private function completeWaterWaveEvent(param1:ImageInfo) : void
        {
            if (this.SimpleWaterParames[4] == param1.name && this._SimpleWaterTexArray[0] == null)
            {
                this._SimpleWaterTexArray[0] = Resource3dManager.instance.getTexture3d(param1.bitmapData, 0);
            }
            if (this.SimpleWaterParames[5] == param1.name && this._SimpleWaterTexArray[1] == null)
            {
                this._SimpleWaterTexArray[1] = Resource3dManager.instance.getTexture3d(param1.bitmapData, 0);
            }
            if (this._SimpleWaterTexArray[0] && this._SimpleWaterTexArray[1])
            {
                this.loadSimpleWaterSkyboxMaps();
            }
            return;
        }// end function

        private function loadSimpleWaterSkyboxMaps() : void
        {
            var _loc_1:* = this.SimpleWaterParames[6];
            var _loc_2:* = this.SimpleWaterParames[7];
            var _loc_3:* = this.SimpleWaterParames[8];
            var _loc_4:* = this.SimpleWaterParames[9];
            var _loc_5:* = this.SimpleWaterParames[10];
            var _loc_6:* = this.SimpleWaterParames[11];
            if (_loc_1 && _loc_2 && _loc_3 && _loc_4 && _loc_5 && _loc_6)
            {
                LoaderManager.instance.load(_loc_1, this.completeWaterMapsEvent);
                LoaderManager.instance.load(_loc_2, this.completeWaterMapsEvent);
                LoaderManager.instance.load(_loc_3, this.completeWaterMapsEvent);
                LoaderManager.instance.load(_loc_4, this.completeWaterMapsEvent);
                LoaderManager.instance.load(_loc_5, this.completeWaterMapsEvent);
                LoaderManager.instance.load(_loc_6, this.completeWaterMapsEvent);
            }
            return;
        }// end function

        private function completeWaterMapsEvent(param1:ImageInfo) : void
        {
            var _loc_4:Texture3D = null;
            var _loc_5:Texture3D = null;
            var _loc_6:Texture3D = null;
            var _loc_7:TextureFilter = null;
            var _loc_8:SimpleWaterNormalFilter = null;
            var _loc_2:* = param1.name;
            var _loc_3:* = EnvMapFilter.anzSkyBoxFileName(_loc_2);
            if (_loc_3[0] == "pos" && _loc_3[1] == "x")
            {
                if (this._SimpleCubeTexArray[0] != null)
                {
                    BitmapData(this._SimpleCubeTexArray[0]).dispose();
                }
                this._SimpleCubeTexArray[0] = param1.bitmapData;
            }
            else if (_loc_3[0] == "neg" && _loc_3[1] == "x")
            {
                this._SimpleCubeTexArray[1] = param1.bitmapData;
            }
            else if (_loc_3[0] == "pos" && _loc_3[1] == "y")
            {
                this._SimpleCubeTexArray[2] = param1.bitmapData;
            }
            else if (_loc_3[0] == "neg" && _loc_3[1] == "y")
            {
                this._SimpleCubeTexArray[3] = param1.bitmapData;
            }
            else if (_loc_3[0] == "pos" && _loc_3[1] == "z")
            {
                this._SimpleCubeTexArray[4] = param1.bitmapData;
            }
            else if (_loc_3[0] == "neg" && _loc_3[1] == "z")
            {
                this._SimpleCubeTexArray[5] = param1.bitmapData;
            }
            if (this._SimpleCubeTexArray[0] && this._SimpleCubeTexArray[1] && this._SimpleCubeTexArray[2] && this._SimpleCubeTexArray[3] && this._SimpleCubeTexArray[4] && this._SimpleCubeTexArray[5])
            {
                _loc_4 = Resource3dManager.instance.getTexture3d(this._SimpleCubeTexArray, 0);
                _loc_5 = Texture3D(this._SimpleWaterTexArray[0]);
                _loc_6 = Texture3D(this._SimpleWaterTexArray[1]);
                _loc_7 = TextureFilter(this.fragmentFilter);
                _loc_8 = new SimpleWaterNormalFilter(_loc_7.texture, _loc_5, _loc_6, _loc_4);
                _loc_8.waterMoveffset[0] = this.SimpleWaterParames[0];
                _loc_8.waterMoveffset[1] = this.SimpleWaterParames[1];
                _loc_8.waterMoveffset[2] = this.SimpleWaterParames[2];
                _loc_8.waterMoveffset[3] = this.SimpleWaterParames[3];
                this.addFilte(_loc_8);
            }
            return;
        }// end function

        public function set enableFog(param1:Boolean) : void
        {
            this._enableFog = param1;
            if (this._enableFog)
            {
                if (!this.hasFilter(FilterType.FogFilter))
                {
                    this.addFilte(new FogFilter(0, Global3D.scene.camera.far * 0.5, this.FogColor));
                }
            }
            else if (this.hasFilter(FilterType.FogFilter))
            {
                this.removeFilteByType(FilterType.FogFilter);
            }
            return;
        }// end function

        public function get enableFog() : Boolean
        {
            return this._enableFog;
        }// end function

        public function set FogColor(param1:uint) : void
        {
            var _loc_2:FogFilter = null;
            this._FogColor = param1;
            if (this.hasFilter(FilterType.FogFilter))
            {
                _loc_2 = this.getFilterByTypeId(FilterType.FogFilter) as FogFilter;
                _loc_2.fogColor = this._FogColor;
            }
            return;
        }// end function

        public function get FogColor() : uint
        {
            return this._FogColor;
        }// end function

        public function SetUvRoll(param1:Boolean, param2:Number, param3:Number) : void
        {
            this._enableUvRoll = param1;
            this._lastTickTime = TimeControler.stageTime;
            this._uvRollSpeed.x = param2;
            this._uvRollSpeed.y = param3;
            return;
        }// end function

        public function update() : void
        {
            var _loc_1:int = 0;
            var _loc_3:Number = NaN;
            var _loc_4:Number = NaN;
            var _loc_5:FilterBase = null;
            if (this._enableUvRoll)
            {
                _loc_3 = TimeControler.stageTime;
                _loc_4 = _loc_3 - this._lastTickTime;
                this._lastTickTime = _loc_3;
                this._uvValue[2] = this._uvValue[2] + _loc_4 * this._uvRollSpeed.x / 10000;
                this._uvValue[3] = this._uvValue[3] + _loc_4 * this._uvRollSpeed.y / 10000;
            }
            var _loc_2:* = this._filterList.length;
            _loc_1 = 0;
            while (_loc_1 < _loc_2)
            {
                
                _loc_5 = this._filterList[_loc_1];
                _loc_5.update();
                _loc_1++;
            }
            return;
        }// end function

        public function SetSecondRollTexture(param1:Boolean, param2:String, param3:Number, param4:Number, param5:Number = 1) : void
        {
            var _loc_6:SecondRollTextureFilter = null;
            var _loc_7:Texture3D = null;
            if (param2 == null || param2 == "")
            {
                param1 = false;
            }
            this._enableSecondRollTexture = param1;
            if (param1)
            {
                if (!this.hasFilter(FilterType.SecondRollTextureFilter))
                {
                    this._secondRollTexturefileName = param2;
                    _loc_7 = Resource3dManager.instance.getTexture3d(param2, Texture3D.MIP_NONE);
                    _loc_6 = new SecondRollTextureFilter(_loc_7);
                    this.addFilte(_loc_6);
                }
                else
                {
                    _loc_6 = this.SecondRollTextureFilter(this.getFilterByTypeId(FilterType.SecondRollTextureFilter));
                    if (param2 != this._secondRollTexturefileName)
                    {
                        this._secondRollTexturefileName = param2;
                        _loc_7 = Resource3dManager.instance.getTexture3d(param2, Texture3D.MIP_NONE);
                        _loc_6.texture = _loc_7;
                        this.needRebuild = true;
                    }
                }
                _loc_6.lightStrength = param5;
                _loc_6.Uspeed = param3;
                _loc_6.Vspeed = param4;
            }
            else
            {
                if (this.hasFilter(FilterType.SecondRollTextureFilter))
                {
                    this.removeFilteByType(FilterType.SecondRollTextureFilter);
                }
                this._secondRollTexturefileName = "";
            }
            return;
        }// end function

    }
}
